//
//  BBSCaseManagerHeaderView.m
//  QuickCure
//
//  Created by 石玄机 on 16/9/14.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "BBSCaseManagerHeaderView.h"

#define kPadding 20

@interface BBSCaseManagerHeaderView ()

@property (weak, nonatomic)  UIImageView *photoView;

@property (weak, nonatomic)  UILabel *gender;

@property (weak, nonatomic)  UILabel *age;

@property (weak, nonatomic)  UILabel *tagID;

@property (weak, nonatomic)  UILabel *phoneNum;

@property (weak, nonatomic)  UILabel *locate;

@property (weak, nonatomic)  UILabel *name;







@end

@implementation BBSCaseManagerHeaderView

-(instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
        
    }
    
    return self;
}

-(void)setupUI{

    //病人图片
    UIImageView *photoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"heima"]];
    [self addSubview:photoView];
    [photoView setContentMode:UIViewContentModeScaleToFill];
    self.photoView = photoView;
    
    UIImageView *iconPerson = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"0"]];
    [self addSubview:iconPerson];
    
    UIImageView *iconTag = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"idCard"]];
    [self addSubview:iconTag];
    
    UIImageView *iconPhone = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"phone"]];
    [self addSubview:iconPhone];
   
    
    UIImageView *iconLocate = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"illness_rb_img_sel.png"]];
    [self addSubview:iconLocate];
    
    
    UILabel *gender = [[UILabel alloc] init];
    gender.text = @"男";
    gender.font = kFONT14;
    [self addSubview:gender];
    self.gender = gender;
    
    UILabel *age = [[UILabel alloc] init];
    age.text = @"28岁";
    age.font = kFONT14;
    [self addSubview:age];
    self.age = age;
    
    UILabel *tagID  = [[UILabel alloc] init];
    tagID.text = @"44944";
    tagID.font = kFONT14;
    [self addSubview:tagID];
    self.tagID = tagID;
    
    UILabel *phoneNum = [[UILabel alloc] init];
    phoneNum.text = @"13743667888";
    phoneNum.font = kFONT14;
    [self addSubview:phoneNum];
    self.phoneNum = phoneNum;
    
    UILabel *locate = [[UILabel alloc] init];
    locate.text = @"上海市";
    locate.font = kFONT14;
    [self addSubview:locate];
    self.locate = locate;
    
    UILabel *name = [[UILabel alloc]init];
    name.text = @"王二狗";
    name.font = kFONT14;
    [self addSubview:name];
    self.name = name;
    
    
    //病人图片
    [photoView makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self).offset(kPadding);
        make.top.equalTo(self).offset(kPadding);
        make.size.equalTo(CGSizeMake(100, 100));
        //FIXME: 图片等比缩放怎么做
    }];
    
    [self.name makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.photoView.bottom).offset(5);
        make.centerX.equalTo(self.photoView);
    }];
    
    [iconPerson makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(photoView.right).offset(kPadding);
        make.top.equalTo(self).offset(kPadding);
        make.size.equalTo(CGSizeMake(kPadding/1.5, kPadding/1.5));
    }];
    
    [iconTag makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(iconPerson.bottom).offset(kPadding/1.3);
        make.centerX.equalTo(iconPerson);
        make.size.equalTo(CGSizeMake(kPadding/1.5, kPadding/1.5));
    }];
    
    [iconPhone makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(iconTag.bottom).offset(kPadding/1.3);
        make.centerX.equalTo(iconTag);
        make.size.equalTo(CGSizeMake(kPadding/1.5, kPadding/1.5));
    }];
    
    [iconLocate makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(iconPhone.bottom).offset(kPadding/1.3);
        make.centerX.equalTo(iconPhone);
        make.size.equalTo(CGSizeMake(kPadding/1.5, kPadding/1.5));
    }];
    
    [self.gender makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(iconPerson);
        make.left.equalTo(iconPerson.right).offset(kPadding);
    }];
    
    [self.age makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.gender);
        make.left.equalTo(self.gender.right).offset(kPadding * 1.5);
    }];
    
    [self.tagID makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(iconTag);
        make.left.equalTo(iconTag.right).offset(kPadding);
    }];
    
    [self.phoneNum makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(iconPhone);
        make.left.equalTo(iconPhone.right).offset(kPadding);
    }];
    
    [self.locate makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(iconLocate);
        make.left.equalTo(iconLocate.right).offset(kPadding);
    }];
}



@end










































